Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: should not set "Content-Encoding" for a direct request of a compressed file #161

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hi-ogawa
Copy link

@hi-ogawa hi-ogawa commented Aug 13, 2024

Content-Encoding should be used only when sirv is serving pre-compressed files (e.g. request: test.csv --> response: test.csv.gz), but it should be avoided when users are requesting a compressed file directly (e.g. test.csv.gz).

Citing from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding

If the original media is encoded in some way (e.g. a zip file) then this information would not be included in the Content-Encoding header.


The summary of changes in this PR is:

  • replace extns: string with extns: { ext: string, encoded: boolean }[],
  • when matching a file with viaLocal or viaCache, it also returns { name: string, encoded: boolean }
  • move Content-Type and Content-Encoding handling from toHeaders to send since it now requires name and encoded to decide these two headers.

Diff looks a little involved, but I hope this is clear and correct. I would appreciate a review. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Downloading gzipped files in browsers
1 participant